package ro.isdc.navigator.retriever.jdbc.strategy;

public abstract class AbstractComputePaginatedSQLStrategy implements
    IComputePaginatedSQLStrategy {

  /**
   * {@inheritDoc}
   */
  @Override
  public PaginatedSQL computePaginatedSQL(String SQL, SQLType sqlType,
      int startIndex, int blockSize) {

    PaginatedSQL generatedSQL = new PaginatedSQL();
    generatedSQL.setPaginatedSQL(buildPaginatedSQL(SQL, sqlType));
    generatedSQL.setLeftLimit(startIndex);
    generatedSQL.setRightLimit(startIndex + blockSize);
    return generatedSQL;
  }
  
  /**
   * Builds the paginated SQL.
   * 
   * @param SQL
   *          the original SQL
   * @param sqlType
   *          the SQL type: indexed or named.
   * @return the paginated SQL
   */
  protected abstract String buildPaginatedSQL(final String SQL, final SQLType sqlType);

}
